<template>
    <div class="link-container">
        <a v-if="NslUtils.isExternal(aToUrl)" :href="aToUrl" target="_blank" rel="noopener">
            <slot></slot>
        </a>
        <div v-else @click="push">
            <slot></slot>
        </div>
    </div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
import { NslUtils } from "@/utils/NslUtil";
import { log } from "console";
defineOptions({
    name: "my_link",
});

const props = defineProps({
    aToUrl: {
        type: String,
        required: true,
    }
});
const router=useRouter();
function push(){
    console.log(props.aToUrl);
    router.push(props.aToUrl).catch((err) => {
        console.error(err);
    });
}
</script>
<style lang="less" scoped></style>
